<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新浪轮播图</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #div1{
            width: 340px;
            height: 300px;
            /*background-color: #bfa;*/
            margin: 50px auto;

        }
        #div01{
            width: 170px;
            height: 300px;
            /*background-color: yellow;*/
            background-image: url("../imagconman/left.png") ;
            display: inline-block;

        }
        #div02{
            width: 170px;
            height: 300px;
            /*background-color: red;;*/
            background-image: url("../imagconman/right.png");
            float: right;
        }
    </style>
    <script>
        window.onload=function () {
            var div01=document.getElementById("div01");
            var div02=document.getElementById("div02");
            var div1=document.getElementById("div1");
                div1.style.backgroundImage="url(../imagconman/2020318.png)";
                div1.style.backgroundRepeat="no-repeat";
            var imgArr=["../imagconman/2020318.png","../imagconman/向日葵.png","../imagconman/荷花.png","../imagconman/荷花.png"];
             var index=0;
                div01.onclick=function () {
                //上一页
                    index--;
                    if (index<0){

                        index=imgArr.length-1;
                    }
                div1.style.backgroundImage="url("+imgArr[index]+")";

                };
                div02.onclick=function () {
                    //向下翻一页
                    index++;
                    if (index>imgArr.length-1){
                        index=0;
                    }
                    div1.style.backgroundImage="url("+imgArr[index]+")";
                };
        }
    </script>
</head>
<body>
<div id="div1">
    <div id="div01"></div>
    <div id="div02"></div>
</div>
</body>
</html>